home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-20 | 2.3 KB | 69 lines | [TEXT/X_#9] |
- ; Tutorial 5: Defining Objects
- ;
- animate 20 ; This file defines a 20-frame animation
- ;
- ; In xModels-2D and xModels-3D, it is possible to define
- ; new "composite" objects which can then be used in exactly
- ; the same way as basic objects like line and circle.
- ; For example:
-
- define wheel ; Begin definition of an object named "wheel".
- [ ; The definition is between a "[" and a "]".
- circle ; List of objects that make up a "wheel".
- line
- line rotate 60
- line rotate 120
- ] ; End of definition of wheel
-
- ; This definition just defines what is meant by a "wheel".
- ; It doesn't add anything to the scene. But once a wheel
- ; has been defined, you can add a wheel to a scene in the
- ; same way you would add a basic object: just list its
- ; name. Furthermore, you can apply transformations to a
- ; wheel. The transformation applies to the wheel as a whole.
-
- wheel ; a wheel (consisting of a circle of diameter
- ; one and three lines of length 1) is shown
- ; in its standard position at the center of
- ; the screen
-
- wheel scale 6 ; a wheel of diameter 6
- rotate 0:60 ; rotating
- translate 5,5 ; and moved so its center is (5,5)
-
- wheel scale 8,3 ; an elliptical "wheel"!
- rotate 0:60
- translate -5,5
-
- wheel rotate 0:60 ; another elliptical "wheel",
- scale 8,3 ; but here the rotation is done
- translate -5,-5 ; before the scaling
-
-
- ; Once an object has been defined, it can even be used in
- ; the definitions of other objects. Also note that an
- ; object can have moving parts, as in this example:
-
- define pinwheel [ ; a spinning bow at the end of a stick
- graypolygon 0,0 1,1 1,-1 -1,1 -1,-1
- rotate 0:-180
- xtranslate 5
- square scale 5.2,0.2 xtranslate 2.5
- ]
-
- define multipin [ ; six pinwheels at various angles
- pinwheel
- pinwheel rotate 60
- pinwheel rotate 120
- pinwheel rotate 180
- pinwheel rotate 240
- pinwheel rotate 300
- ;circle scale 7
- ]
-
- multipin
- scale 0.5
- rotate 0:60
- translate 5,-5
-
-